import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zhongyiapp/pages/index.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: LoginScreen(),
    );
  }
}

class LoginScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Stack(fit: StackFit.expand, children: <Widget>[
      // 背景图片
      Image.asset(
        'assets/背景图1.png', // 替换为你的图片路径
        fit: BoxFit.cover,
      ),
      // 登录表单
      Container(
        decoration: BoxDecoration(
          color: Colors.white.withOpacity(0.1), // 半透明覆盖层，以便文本可见
        ),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                '医 智 方 剂 通',
                style: TextStyle(
                    fontSize: 50.0,
                    fontWeight: FontWeight.bold,
                    color: Color.fromARGB(255, 176, 127, 55),
                    fontFamily: '行楷'),
              ),
              SizedBox(height: 60.0), // 调整文本和按钮之间的空间
              ElevatedButton(
                onPressed: () {
                  // 按钮点击事件
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (context) => Indexscreen(),
                    ),
                  );
                },
                child: Text(
                  '本机号码一键登录',
                  style: TextStyle(fontSize: 20.0, fontFamily: '行楷'),
                ),
                style: ElevatedButton.styleFrom(
                    foregroundColor: Colors.white,
                    backgroundColor: Color.fromARGB(255, 176, 127, 55)),
              ),
              SizedBox(height: 20.0), // 调整按钮和文本之间的空间
              Text(
                '其他账号登录',
                style: TextStyle(
                  fontSize: 16.0,
                  color: Colors.grey,
                ),
              ),
              SizedBox(height: 50.0), // 调整文本和图标之间的空间
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Column(
                    children: <Widget>[
                      Icon(Icons.vpn_key,
                          size: 30.0, color: Color.fromARGB(255, 176, 127, 55)),
                      SizedBox(height: 10.0), // 调整图标和文本之间的空间
                      Text(
                        '验证码登录',
                        style: TextStyle(
                          fontSize: 16.0,
                          color: Colors.black,
                        ),
                      ),
                    ],
                  ),
                  SizedBox(width: 40.0), // 调整两个图标之间的空间
                  Column(
                    children: <Widget>[
                      // 微信图标
                      Icon(Icons.chat,
                          size: 30.0, color: Color.fromARGB(255, 176, 127, 55)),
                      SizedBox(height: 10.0), // 调整图标和文本之间的空间
                      Text(
                        '微信登录',
                        style: TextStyle(
                          fontSize: 16.0,
                          color: Colors.black,
                        ),
                      ),
                    ],
                  ),
                ],
              ),
              SizedBox(height: 40.0), // 调整图标和文本之间的空间
              CheckboxDemo()
            ],
          ),
        ),
      ),
    ]));
  }
}

class CheckboxDemo extends StatefulWidget {
  @override
  _CheckboxDemoState createState() => _CheckboxDemoState();
}

class _CheckboxDemoState extends State<CheckboxDemo> {
  bool _agreed = false;

  void _toggleCheckbox(bool? value) {
    setState(() {
      _agreed = value!;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Checkbox(
                value: _agreed,
                onChanged: _toggleCheckbox,
                activeColor: Colors.blue,
              ),
              // 在复选框和文本之间添加一些间距
              Text(
                '登录即代表您同意《隐私政策》与《用户协议》',
                style: TextStyle(
                  fontSize: 16.0,
                  color: Colors.grey,
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ),
          SizedBox(height: 40.0), // 调整图标和文本之间的空间
        ],
      ),
    );
  }
}
